<?php
class CsvController extends NodeController {
	
	public function i() {
		//存放uid
		$rs = self::getCSVService ()->stats ( $this->_user_global ['uid'] );
		$this->view ()->assign ( 'stats', $rs ); //当前累计订单数
		

		$this->view ()->assign ( 'user', $this->_user_global );
		$this->view ()->display ( "mysql:uploadify.tpl" );
	}
	
	public function export() {
		
		self::getCSVService ()->export ( $this->_user_global ['uid'] );
	}
	
	public function upload() {
		
		// 验证码
		

		$user = $this->_user_global;
		$flag = self::getCSVService ()->import ( $_POST ['timestamp'], $_POST ['token'], $user );
		
		if ($flag == "success") {
			echo "上传成功  <a href='/csv/i'>点击返回</a>";
		} else {
			echo $flag;
			echo "<a href='/csv/i'>点击返回</a>";
		}
	}
	
	public static function getCSVService() {
		return new CSVService ();
	}
}